#ifndef __THREAD_MANAGE_H
#define __THREAD_MANAGE_H

#include "md_thread.h"
#include "md_sysmsg.h"
#include "list.h"
#include "common_conf.h"
#include "thread_event.h"

typedef enum
{
    EVENT_PROCESS_NON_BLOCK = 0,	//非阻塞
	EVENT_PROCESS_BLOCK,			//阻塞
}EVENT_PROCESS_E;

typedef enum
{
    THREAD_EVENT_DISABLE = 0,	//不使能事件工具
	THREAD_EVENT_ENABLE,		//使能事件工具
}THREAD_EVENT_TYPE_E;

typedef struct	_t_thread_info{

	pthread_t thread_arg;	//线程句柄
	char *thread_name;		//线程名称
	int heart_cnt;			//线程心跳计数器
	uint8_t num;			//加入thread_manage之后分配的编号
	
	int msqid;				//事件句柄
	t_event_listen event_listen_list;//事件监听信息
	struct list_head list;	
}t_thread_info;

int thread_manage_init(int is_enable);

t_thread_info *thread_info_malloc(char *name);

void thread_info_free(t_thread_info *thread_info);

int thread_manage_member_add(t_thread_info *thread_info, THREAD_EVENT_TYPE_E e);

int thread_manage_member_del(int event_used);

int thread_manage_event_listen(int event_id, void *user_data, event_callback_func cb);

int thread_manage_event_unlisten(int event_id);

int thread_manage_event_listen_process(EVENT_PROCESS_E type);

int thread_manage_event_msg_send(char * thread_name, int event_id, void *arg );


#endif
